package com.rainsoft.center.isec.stream;

import com.rainsoft.center.isec.common.entity.RedisBaseInfo;
import com.rainsoft.center.isec.common.utils.JDBCHelper;
import com.rainsoft.center.isec.common.utils.JedisUtil;
import com.rainsoft.center.isec.stream.base.IBaseDataLoad;
import com.rainsoft.center.isec.stream.library.controller.impl.RealidDataLoad;
import com.rainsoft.center.isec.stream.library.entity.hbase.impl.RealidLoginout;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @Name com.rainsoft.center.isec.stream.Start
 * @Description
 * @Author Elwyn
 * @Version 2017/11/21
 * @Copyright 上海云辰信息科技有限公司
 **/
public class Start {


	public static void main(String[] args) {
		//Logger.getLogger("org").setLevel(Level.ERROR);


		String sql = "SELECT s.id      \"serviceId\",\n" +
				"       s.name    \"serviceName\",\n" +
				"       s.code    \"serviceCode\",\n" +
				"       s.address \"serviceAddress\",\n" +
				"       s.type    \"serviceType\",\n" +
				"       s.latitude serviceLatitude,\n" +
				"       s.longitude serviceLongitude,\n" +
				"       s.AREA_CODE areaCode,\n" +
				"       s.POLICE_CODE policeCode,\n" +
				"       m.id      \"machineId\",\n" +
				"       m.code    \"machineCode\",\n" +
				"       m.name    \"machineName\",\n" +
				"       m.address \"machineAddress\",\n" +
				"       m.type    \"machineType\",\n" +
				"       m.latitude machineLatitude,\n" +
				"       m.longitude machineLongitude\n" +
				"  FROM machine_info m, service_info s\n" +
				" WHERE m.service_id = s.id";

		JDBCHelper instance = JDBCHelper.getInstance();
		List<RedisBaseInfo> redisBaseInfos = instance.queryForList(sql, new Object[]{}, RedisBaseInfo.class);
		JedisUtil.set("listBaseInfo", redisBaseInfos);
		for (RedisBaseInfo redisBaseInfo : redisBaseInfos) {
			JedisUtil.set(redisBaseInfo.getMachineCode(), redisBaseInfo);
		}

		IBaseDataLoad baseContentDataLoad = new RealidDataLoad(10, RealidLoginout.class);
		//IBaseDataLoad baseContentDataLoad= new BaseContentDataLoad<>(5, WeiboContent.class);
		baseContentDataLoad.process();
	}
}
